import { Action } from "@ngrx/store";
import {
  ILoginRequest,
  IFindUserRequest,
  IFindUserResponse,
  IEnrollRequest,
  IEnrollResponse,
  ILoginResponse,
  ISavePwdRequest,
  ISavePwdResponse,
  ILogoutRequest,
  ILogoutResponse
} from "../models/user";
export enum UserActionTypes {
  Login = "[User] Login",
  LoginSuccess = "[User] Login Success",
  LoginError = "[User] Login Error",
  FindUser = "[User] Find User",
  FindUserSuccess = "[User] Find User Success",
  FindUserError = "[User] Find User Error",
  Enroll = "[User] Enroll",
  EnrollSuccess = "[User] Enroll Success",
  EnrollError = "[User] Enroll Error",
  SavePwd = "[User] Find Pwd",
  SavePwdSuccess = "[User] Find Pwd Success",
  SavePwdError = "[User] Find Pwd Error",

  Logout = "[User] Logout",
  LogoutSuccess = "[User] Logout Success",
  LogoutError = "[User] Logout Error"
}

export class Login implements Action {
  readonly type = UserActionTypes.Login;
  constructor(public payload: { req: ILoginRequest; cpt: any }) {}
}

export class LoginSuccess implements Action {
  readonly type = UserActionTypes.LoginSuccess;
  constructor(public payload: { res: ILoginResponse; cpt: any }) {}
}

export class LoginError implements Action {
  readonly type = UserActionTypes.LoginError;
  constructor(public payload: { error: any }) {}
}

export class FindUser implements Action {
  readonly type = UserActionTypes.FindUser;
  constructor(public payload: { req: IFindUserRequest }) {}
}

export class FindUserSuccess implements Action {
  readonly type = UserActionTypes.FindUserSuccess;
  constructor(public payload: { res: IFindUserResponse }) {}
}

export class FindUserError implements Action {
  readonly type = UserActionTypes.FindUserError;
  constructor(public payload: { error: any }) {}
}

export class SavePwd implements Action {
  readonly type = UserActionTypes.SavePwd;
  constructor(public payload: { req: ISavePwdRequest; cpt: any }) {}
}

export class SavePwdSuccess implements Action {
  readonly type = UserActionTypes.SavePwdSuccess;
  constructor(public payload: { res: ISavePwdResponse; cpt: any }) {}
}

export class SavePwdError implements Action {
  readonly type = UserActionTypes.SavePwdError;
  constructor(public payload: { error: any }) {}
}

export class Enroll implements Action {
  readonly type = UserActionTypes.Enroll;
  constructor(public payload: { req: IEnrollRequest; cpt: any }) {}
}

export class EnrollSuccess implements Action {
  readonly type = UserActionTypes.EnrollSuccess;
  constructor(public payload: { res: IEnrollResponse; cpt: any }) {}
}

export class EnrollError implements Action {
  readonly type = UserActionTypes.EnrollError;
  constructor(public payload: { error: any }) {}
}

export class Logout implements Action {
  readonly type = UserActionTypes.Logout;
  constructor(public payload: { req: ILogoutRequest; cpt: any }) {}
}

export class LogoutSuccess implements Action {
  readonly type = UserActionTypes.LogoutSuccess;
  constructor(public payload: { res: ILogoutResponse; cpt: any }) {}
}

export class LogoutError implements Action {
  readonly type = UserActionTypes.LogoutError;
  constructor(public payload: { error: any }) {}
}

export type UserActionsUnion =
  | LogoutError
  | LogoutSuccess
  | Logout
  | Enroll
  | EnrollSuccess
  | EnrollError
  | Logout
  | Login
  | LoginSuccess
  | LoginError
  | SavePwd
  | SavePwdSuccess
  | SavePwdError
  | FindUser
  | FindUserSuccess
  | FindUserError;
